﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace PressMenu2 
{
    class CungTen : GameObject
    {
        private bool free = true;
        public CungTen(int id, int player) : base(id,player)
        {
            texture = MyResource.tCungTen[id];
            Position = new Vector2(cDef.TAM.X, cDef.WindowHeight);
            rectangle = new Rectangle((int)Position.X, (int)Position.Y, texture.Width, texture.Height);
            this.Blood = 30;
        }

        public override int Update(GameTime gameTime, MyInput input)
        {
            float dx = input.Mouse.X - cDef.TAM.X;
            float dy = input.Mouse.Y - cDef.TAM.Y;
            if (dy != 0)
                Angle = -(float)Math.Atan(dx / dy);
            return 0;
        }

        public override void Render(SpriteBatch sb)
        {
            Rectangle srcRect = new Rectangle(0, 0, texture.Width, texture.Height);
            sb.Draw(texture, position, srcRect, Color.White, angle, new Vector2(texture.Width / 2, texture.Height), new Vector2(1, 1), SpriteEffects.None, 1f);
            sb.DrawString(MyResource.fontArial25, Blood.ToString(), position + new Vector2(0, -100), Color.Blue);
        }

        public override float Angle
        {
            get { return this.angle; }
            set {
                this.angle = value; 
                cDef.angle = value;
            }
        }


        public bool Free
        {
            get { return free; }
            set { free = value; }
        }
    }
}
